<script type="text/javascript">
	addTab("<?php echo Core_Util::escapeForJs2($this->contest->title)?>",'<?php echo $this->url();?>')
</script>
<?php
	if ($this->contest->isFinishedTimeline()):
?>
<script type="text/javascript" src="<?php echo STATIC_URL .  "/javascript/highcharts.js"?>"></script>
<div id="campaign_container">
	<h1><?php echo $this->translate('CAMPAIGN_REPORT'); ?></h1>
	<div id="campaign_summary">
		<table class="campaign_headline">
			<tbody>
				<tr>
					<td><?php echo $this->translate('NAME');?></td>
					<td colspan="4"><?php echo $this->escape($this->contest->title);?></td>
				</tr>
				<tr>
					<td><?php echo $this->translate('DURATION');?></td>
					<td colspan="4"><?php echo sprintf($this->translate('REPORT_DURATION'), Date("M d, Y", $this->listPhase[0]['date_start']), Date("M d, Y", $this->listPhase[count($this->listPhase)-1]['date_end']))?></td>
				</tr>
			</tbody>
		</table>
		<table class="campaign_detail">
			<tbody>
				<tr>
					<td><?php echo $this->translate('STATISTIC_TOTAL_VISITORS')?></td>
					<td class=""><?php echo $this->statisticData['visitor']?></td>
					<td><?php echo $this->translate('STATISTIC_TOTAL_ENTRIES')?></td>
					<td><?php echo $this->statisticData['entries']?></td>
					<td><a class="report" href="<?php echo $this->url(array('action' => 'export-entries'))?>"><?php echo $this->translate('EXPORT_ENTRIES') ?></a></td>
				</tr>
				<tr>
					<td><?php echo $this->translate('STATISTIC_TOTAL_NEW_FANS')?></td>
					<td><?php echo $this->statisticData['new_fan']?></td>
					<td><?php echo $this->translate('STATISTIC_TOTAL_REGISTRANTS')?></td>
					<td><?php echo $this->statisticData['registrants']?></td>
					<td><a class="report" href="<?php echo $this->url(array('action' => 'export-registrants'))?>"><?php echo $this->translate('EXPORT_REGISTRANTS') ?></td>
				</tr>
				<tr>
					<td><?php echo $this->translate('STATISTIC_TOTAL_VOTES')?></td>
					<td><?php echo $this->statisticData['votes']?></td>
					<td><?php echo $this->translate('STATISTIC_TOTAL_VOTERS')?></td>
					<td><?php echo $this->statisticData['voter']?></td>
					<td><a class="report" href="<?php echo $this->url(array('action' => 'export-voters'))?>"><?php echo $this->translate('EXPORT_VOTERS') ?></td>
				</tr>
			</tbody>
		</table>
	</div>
	<?php
		echo $this->form;
	?>
	<?php if ($this->form->isErrors()):?>
	<ul class="errors">
		<?php foreach ($this->form->getMessages() as $k => $errs): ?>
			<?php foreach ($errs as $e ):?>
			<li>
				<?php echo $e;?>
			</li>
			<?php endforeach;?>
		<?php endforeach;?>	
	</ul>	
	<?php endif;?>

	<div id="activity_zone">
		<h2><?php echo sprintf($this->translate('REPORT_TRAFFIC'), $this->fromDate, $this->toDate)?></h2>
		<div id="traffic_container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
	</div>

	<div id="activity_zone">
		<h2><?php echo sprintf($this->translate('REPORT_ACTIVITY'), $this->fromDate, $this->toDate)?></h2>
		<div class="activity control">
			<?php
			if ($this->fromDate !== 'N/A')
				echo $this->activtyForm;
			?>
		</div>
		<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
	</div>
	
	<div id="gender_age">
		<h2><?php echo sprintf($this->translate('REPORT_DEMOGRAPHIC'), $this->fromDate, $this->toDate)?></h2>
		<div class="demographic control">
			<?php
			if ($this->fromDate !== 'N/A')
				echo $this->demographicForm;
			?>
		</div>
		<div id="gender_age_container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
	</div>
</div>
<script>
$('#campaign_container').ymStatistic({
	'base_url' : '<?php echo $this->baseUrl('contest/report/index/id/'. $this->contest->id)?>',
	chartDataUrl : "<?php echo $this->baseUrl('contest/report/chart-data/id/'. $this->contest->id) ?>",
	minDate : '<?php echo Date("m/d/Y", $this->contest->time_created);?>',
	maxDate : '<?php echo Date("m/d/Y",  $this->listPhase[count($this->listPhase)-1]['date_end']);?>',
	range : <?php echo json_encode($this->range)?>,
	rangeAgeGender : <?php echo json_encode($this->rangeAgeGender);?>,
	dataTraffic : <?php echo json_encode($this->dataTraffic)?>,
	dataPerformance : <?php echo json_encode($this->dataPerformance)?>,
	dataAgeGender : <?php echo json_encode($this->dataAgeGender);?>,
	startDate: '<?php echo !empty($this->fromDate) ? strtotime($this->fromDate) : -1;?>',
	today: '<?php echo Date("m/d/Y",  time());?>'
})

</script>
<?php else:?>
<div id="campaign_container">
	<h1><?php echo $this->translate('CAMPAIGN_REPORT'); ?></h1>
	<div id="campaign_summary">
		<table class="campaign_headline">
			<tbody>
				<tr>
					<td><?php echo $this->translate('NAME');?></td>
					<td colspan="4"><?php echo $this->escape($this->contest->title);?></td>
				</tr>
				<tr>
					<td><?php echo $this->translate('DURATION');?></td>
					<td colspan="4">N/A</td>
				</tr>
			</tbody>
		</table>
	</div>
	<p class="errors_parnel">
		<?php echo sprintf($this->translate('REPORT_NOT_FULLY_CONFIGURE_MESSAGE'), $this->url(array(
			'module'	=>	'contest',
			'controller'=>	'manage',
			'action'	=>	'create-phase',
			'id'		=>	$this->contest->id
		), null, true), $this->escape($this->contest->title)
				);?>
	</p>
</div>
<?php endif; ?>
